﻿using System;
using System.Data;
using System.Text;
using System.Data.OracleClient;
using Maticsoft.DBUtility;//Please add references
namespace ORSIMS.DAL
{
	/// <summary>
	/// 数据访问类:IMAGE_MEDTADATA_AERIAL
	/// </summary>
	public partial class IMAGE_MEDTADATA_AERIAL
	{
		public IMAGE_MEDTADATA_AERIAL()
		{}
		#region  BasicMethod



		/// <summary>
		/// 增加一条数据
		/// </summary>
		public bool Add(ORSIMS.Model.IMAGE_MEDTADATA_AERIAL model)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("insert into IMAGE_MEDTADATA_AERIAL(");
			strSql.Append("ID,IMGID,CODENAME,ADMINISTRATIVEDIVISIONS,LENSNUMBER,FOCUS,PIXELSIZE,PRODUCTIONUNIT,COMPLETIONTIME,SHOOTINGAREA,SHEETNUMBER,APPROACHTIME,DEPARTURETIME,AIRFIELD,AERIALDAYS,POSTYPE)");
			strSql.Append(" values (");
			strSql.Append(":ID,:IMGID,:CODENAME,:ADMINISTRATIVEDIVISIONS,:LENSNUMBER,:FOCUS,:PIXELSIZE,:PRODUCTIONUNIT,:COMPLETIONTIME,:SHOOTINGAREA,:SHEETNUMBER,:APPROACHTIME,:DEPARTURETIME,:AIRFIELD,:AERIALDAYS,:POSTYPE)");
			OracleParameter[] parameters = {
					new OracleParameter(":ID", OracleType.Number,8),
					new OracleParameter(":IMGID", OracleType.VarChar,32),
					new OracleParameter(":CODENAME", OracleType.VarChar,20),
					new OracleParameter(":ADMINISTRATIVEDIVISIONS", OracleType.VarChar,20),
					new OracleParameter(":LENSNUMBER", OracleType.VarChar,20),
					new OracleParameter(":FOCUS", OracleType.Number,5),
					new OracleParameter(":PIXELSIZE", OracleType.Number,5),
					new OracleParameter(":PRODUCTIONUNIT", OracleType.VarChar,20),
					new OracleParameter(":COMPLETIONTIME", OracleType.DateTime),
					new OracleParameter(":SHOOTINGAREA", OracleType.Number,5),
					new OracleParameter(":SHEETNUMBER", OracleType.Number,5),
					new OracleParameter(":APPROACHTIME", OracleType.DateTime),
					new OracleParameter(":DEPARTURETIME", OracleType.DateTime),
					new OracleParameter(":AIRFIELD", OracleType.VarChar,20),
					new OracleParameter(":AERIALDAYS", OracleType.Number,4),
					new OracleParameter(":POSTYPE", OracleType.VarChar,20)};
			parameters[0].Value = model.ID;
			parameters[1].Value = model.IMGID;
			parameters[2].Value = model.CODENAME;
			parameters[3].Value = model.ADMINISTRATIVEDIVISIONS;
			parameters[4].Value = model.LENSNUMBER;
			parameters[5].Value = model.FOCUS;
			parameters[6].Value = model.PIXELSIZE;
			parameters[7].Value = model.PRODUCTIONUNIT;
			parameters[8].Value = model.COMPLETIONTIME;
			parameters[9].Value = model.SHOOTINGAREA;
			parameters[10].Value = model.SHEETNUMBER;
			parameters[11].Value = model.APPROACHTIME;
			parameters[12].Value = model.DEPARTURETIME;
			parameters[13].Value = model.AIRFIELD;
			parameters[14].Value = model.AERIALDAYS;
			parameters[15].Value = model.POSTYPE;

			int rows=DbHelperOra.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}
		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update(ORSIMS.Model.IMAGE_MEDTADATA_AERIAL model)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("update IMAGE_MEDTADATA_AERIAL set ");
			strSql.Append("ID=:ID,");
			strSql.Append("IMGID=:IMGID,");
			strSql.Append("CODENAME=:CODENAME,");
			strSql.Append("ADMINISTRATIVEDIVISIONS=:ADMINISTRATIVEDIVISIONS,");
			strSql.Append("LENSNUMBER=:LENSNUMBER,");
			strSql.Append("FOCUS=:FOCUS,");
			strSql.Append("PIXELSIZE=:PIXELSIZE,");
			strSql.Append("PRODUCTIONUNIT=:PRODUCTIONUNIT,");
			strSql.Append("COMPLETIONTIME=:COMPLETIONTIME,");
			strSql.Append("SHOOTINGAREA=:SHOOTINGAREA,");
			strSql.Append("SHEETNUMBER=:SHEETNUMBER,");
			strSql.Append("APPROACHTIME=:APPROACHTIME,");
			strSql.Append("DEPARTURETIME=:DEPARTURETIME,");
			strSql.Append("AIRFIELD=:AIRFIELD,");
			strSql.Append("AERIALDAYS=:AERIALDAYS,");
			strSql.Append("POSTYPE=:POSTYPE");
			strSql.Append(" where ");
			OracleParameter[] parameters = {
					new OracleParameter(":ID", OracleType.Number,8),
					new OracleParameter(":IMGID", OracleType.VarChar,32),
					new OracleParameter(":CODENAME", OracleType.VarChar,20),
					new OracleParameter(":ADMINISTRATIVEDIVISIONS", OracleType.VarChar,20),
					new OracleParameter(":LENSNUMBER", OracleType.VarChar,20),
					new OracleParameter(":FOCUS", OracleType.Number,5),
					new OracleParameter(":PIXELSIZE", OracleType.Number,5),
					new OracleParameter(":PRODUCTIONUNIT", OracleType.VarChar,20),
					new OracleParameter(":COMPLETIONTIME", OracleType.DateTime),
					new OracleParameter(":SHOOTINGAREA", OracleType.Number,5),
					new OracleParameter(":SHEETNUMBER", OracleType.Number,5),
					new OracleParameter(":APPROACHTIME", OracleType.DateTime),
					new OracleParameter(":DEPARTURETIME", OracleType.DateTime),
					new OracleParameter(":AIRFIELD", OracleType.VarChar,20),
					new OracleParameter(":AERIALDAYS", OracleType.Number,4),
					new OracleParameter(":POSTYPE", OracleType.VarChar,20)};
			parameters[0].Value = model.ID;
			parameters[1].Value = model.IMGID;
			parameters[2].Value = model.CODENAME;
			parameters[3].Value = model.ADMINISTRATIVEDIVISIONS;
			parameters[4].Value = model.LENSNUMBER;
			parameters[5].Value = model.FOCUS;
			parameters[6].Value = model.PIXELSIZE;
			parameters[7].Value = model.PRODUCTIONUNIT;
			parameters[8].Value = model.COMPLETIONTIME;
			parameters[9].Value = model.SHOOTINGAREA;
			parameters[10].Value = model.SHEETNUMBER;
			parameters[11].Value = model.APPROACHTIME;
			parameters[12].Value = model.DEPARTURETIME;
			parameters[13].Value = model.AIRFIELD;
			parameters[14].Value = model.AERIALDAYS;
			parameters[15].Value = model.POSTYPE;

			int rows=DbHelperOra.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete()
		{
			//该表无主键信息，请自定义主键/条件字段
			StringBuilder strSql=new StringBuilder();
			strSql.Append("delete from IMAGE_MEDTADATA_AERIAL ");
			strSql.Append(" where ");
			OracleParameter[] parameters = {
			};

			int rows=DbHelperOra.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}


		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public ORSIMS.Model.IMAGE_MEDTADATA_AERIAL GetModel()
		{
			//该表无主键信息，请自定义主键/条件字段
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select ID,IMGID,CODENAME,ADMINISTRATIVEDIVISIONS,LENSNUMBER,FOCUS,PIXELSIZE,PRODUCTIONUNIT,COMPLETIONTIME,SHOOTINGAREA,SHEETNUMBER,APPROACHTIME,DEPARTURETIME,AIRFIELD,AERIALDAYS,POSTYPE from IMAGE_MEDTADATA_AERIAL ");
			strSql.Append(" where ");
			OracleParameter[] parameters = {
			};

			ORSIMS.Model.IMAGE_MEDTADATA_AERIAL model=new ORSIMS.Model.IMAGE_MEDTADATA_AERIAL();
			DataSet ds=DbHelperOra.Query(strSql.ToString(),parameters);
			if(ds.Tables[0].Rows.Count>0)
			{
				return DataRowToModel(ds.Tables[0].Rows[0]);
			}
			else
			{
				return null;
			}
		}


		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public ORSIMS.Model.IMAGE_MEDTADATA_AERIAL DataRowToModel(DataRow row)
		{
			ORSIMS.Model.IMAGE_MEDTADATA_AERIAL model=new ORSIMS.Model.IMAGE_MEDTADATA_AERIAL();
			if (row != null)
			{
				if(row["ID"]!=null && row["ID"].ToString()!="")
				{
					model.ID=decimal.Parse(row["ID"].ToString());
				}
				if(row["IMGID"]!=null)
				{
					model.IMGID=row["IMGID"].ToString();
				}
				if(row["CODENAME"]!=null)
				{
					model.CODENAME=row["CODENAME"].ToString();
				}
				if(row["ADMINISTRATIVEDIVISIONS"]!=null)
				{
					model.ADMINISTRATIVEDIVISIONS=row["ADMINISTRATIVEDIVISIONS"].ToString();
				}
				if(row["LENSNUMBER"]!=null)
				{
					model.LENSNUMBER=row["LENSNUMBER"].ToString();
				}
				if(row["FOCUS"]!=null && row["FOCUS"].ToString()!="")
				{
					model.FOCUS=decimal.Parse(row["FOCUS"].ToString());
				}
				if(row["PIXELSIZE"]!=null && row["PIXELSIZE"].ToString()!="")
				{
					model.PIXELSIZE=decimal.Parse(row["PIXELSIZE"].ToString());
				}
				if(row["PRODUCTIONUNIT"]!=null)
				{
					model.PRODUCTIONUNIT=row["PRODUCTIONUNIT"].ToString();
				}
				if(row["COMPLETIONTIME"]!=null && row["COMPLETIONTIME"].ToString()!="")
				{
					model.COMPLETIONTIME=DateTime.Parse(row["COMPLETIONTIME"].ToString());
				}
				if(row["SHOOTINGAREA"]!=null && row["SHOOTINGAREA"].ToString()!="")
				{
					model.SHOOTINGAREA=decimal.Parse(row["SHOOTINGAREA"].ToString());
				}
				if(row["SHEETNUMBER"]!=null && row["SHEETNUMBER"].ToString()!="")
				{
					model.SHEETNUMBER=decimal.Parse(row["SHEETNUMBER"].ToString());
				}
				if(row["APPROACHTIME"]!=null && row["APPROACHTIME"].ToString()!="")
				{
					model.APPROACHTIME=DateTime.Parse(row["APPROACHTIME"].ToString());
				}
				if(row["DEPARTURETIME"]!=null && row["DEPARTURETIME"].ToString()!="")
				{
					model.DEPARTURETIME=DateTime.Parse(row["DEPARTURETIME"].ToString());
				}
				if(row["AIRFIELD"]!=null)
				{
					model.AIRFIELD=row["AIRFIELD"].ToString();
				}
				if(row["AERIALDAYS"]!=null && row["AERIALDAYS"].ToString()!="")
				{
					model.AERIALDAYS=decimal.Parse(row["AERIALDAYS"].ToString());
				}
				if(row["POSTYPE"]!=null)
				{
					model.POSTYPE=row["POSTYPE"].ToString();
				}
			}
			return model;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select ID,IMGID,CODENAME,ADMINISTRATIVEDIVISIONS,LENSNUMBER,FOCUS,PIXELSIZE,PRODUCTIONUNIT,COMPLETIONTIME,SHOOTINGAREA,SHEETNUMBER,APPROACHTIME,DEPARTURETIME,AIRFIELD,AERIALDAYS,POSTYPE ");
			strSql.Append(" FROM IMAGE_MEDTADATA_AERIAL ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			return DbHelperOra.Query(strSql.ToString());
		}

		/// <summary>
		/// 获取记录总数
		/// </summary>
		public int GetRecordCount(string strWhere)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select count(1) FROM IMAGE_MEDTADATA_AERIAL ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			object obj = DbHelperSQL.GetSingle(strSql.ToString());
			if (obj == null)
			{
				return 0;
			}
			else
			{
				return Convert.ToInt32(obj);
			}
		}
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("SELECT * FROM ( ");
			strSql.Append(" SELECT ROW_NUMBER() OVER (");
			if (!string.IsNullOrEmpty(orderby.Trim()))
			{
				strSql.Append("order by T." + orderby );
			}
			else
			{
				strSql.Append("order by T. desc");
			}
			strSql.Append(")AS Row, T.*  from IMAGE_MEDTADATA_AERIAL T ");
			if (!string.IsNullOrEmpty(strWhere.Trim()))
			{
				strSql.Append(" WHERE " + strWhere);
			}
			strSql.Append(" ) TT");
			strSql.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);
			return DbHelperOra.Query(strSql.ToString());
		}

		/*
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public DataSet GetList(int PageSize,int PageIndex,string strWhere)
		{
			OracleParameter[] parameters = {
					new OracleParameter(":tblName", OracleType.VarChar, 255),
					new OracleParameter(":fldName", OracleType.VarChar, 255),
					new OracleParameter(":PageSize", OracleType.Number),
					new OracleParameter(":PageIndex", OracleType.Number),
					new OracleParameter(":IsReCount", OracleType.Clob),
					new OracleParameter(":OrderType", OracleType.Clob),
					new OracleParameter(":strWhere", OracleType.VarChar,1000),
					};
			parameters[0].Value = "IMAGE_MEDTADATA_AERIAL";
			parameters[1].Value = "";
			parameters[2].Value = PageSize;
			parameters[3].Value = PageIndex;
			parameters[4].Value = 0;
			parameters[5].Value = 0;
			parameters[6].Value = strWhere;	
			return DbHelperOra.RunProcedure("UP_GetRecordByPage",parameters,"ds");
		}*/

		#endregion  BasicMethod
		#region  ExtensionMethod

		#endregion  ExtensionMethod
	}
}

